<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$this->load->database();
$bar="Result of search by Salary";
        echo '<table class="tablebg" cellspacing="1" align="right" border="1" width="900px">';
        echo '<tr><td colspan=8 align=right class=bar>'.$bar.'</td></tr>';
        echo '<tr><td colspan=8 align=right class=bar>Totals of results: '.$total_rows.'</td></tr>';
        echo '<tr><td colspan=8 align=right class=pagination>'.$pagination.'</td></tr>';
        echo '
              <th>userid</th>
              <th>fullname</th>
              <th>starttime</th>
              <th>endtime</th>
              <th>overtime</th>
              <th>daytime</th>
              <th>weekday</th>
              <th>Action</th>';
        foreach($query->result() as $row){
            //$images='<img src="'.base_url().'application/templates/images/'.$row->staff_avarta.'" width=100 height=70>';
            //$details = anchor("user/loadUpdateForm/$row->Staff_ID",$images);
            echo "<tr>
                        <td class=\"row1\">$row->userid</td>";
            $sql="select * from ewt_users where id=$row->userid";
            $query1=$this->db->query($sql);
            foreach ($query1->result() as $row1)
            {
            echo "<td class=\"row1\">$row1->fullname</td>";
                    
                    
            }
            echo "<td class=\"row1\">$row->starttime</td>";
                  
            echo "<td class=\"row1\">$row->endtime</td>
                        <td class=\"row1\">$row->overtime</td>";
            if(isset($row->starttime))
            {
            echo "<td class=\"row1\">08:00</td>";
            }
                
            echo "<td class=\"row1\">$row->weekday</td></tr>";
            
            
            /*$titleUpdate = '<img src ="'.base_url().'templates/images/icons/edit.gif" title="Click here to modify"/>';
            $titleDelete = '<img src ="'.base_url().'templates/images/icons/delete.png" title="Click here to delete"/>';
            //$titleActive = '<img src ="'.base_url().'application/templates/images/icons/active.jpg" title="Click here to active"/>';
            $titleView = '<img src ="'.base_url().'templates/images/icons/view.gif" height=25 title="Click here to view "/>';
            $titleInsertFamily = '<img src ="'.base_url().'templates/images/icons/insert_family.jpeg" width=40 height=25 title="Click here to insert family"/>';
            $update = anchor("staff/loadStaffUpdateForm/$row->Staff_ID",$titleUpdate);
            $delete = anchor("staff/deleteStaff/$row->Staff_ID",$titleDelete);
            //$active = anchor("user/loadConfirmForm/$row->Staff_ID",$titleActive);
            $view_staff=anchor("staff/viewInformationStaff/$row->Staff_ID",$titleView);
            $insert_family=anchor("staff/loadListFamily/$row->Staff_ID",$titleInsertFamily);
            echo "<td class=\"row1\" align=\"center\">$update $delete $view_staff $insert_family</td></tr>";*/
            }
            /*$titleInsert = '<img src ="'.base_url().'templates/images/icons/addstaff.jpeg" width=60 height=40 title="Click here to insert staff"/>';
            $insert = anchor("staff/loadInterviewerPass",$titleInsert);
            echo '<tr><td colspan=5 align=center>'.$insert.'</td></tr>';
            echo '<tr><td colspan=5 align=right class=pagination>'.$pagination.'</td></tr>';*/
            
            $a=0;$b=0;$c=0;$d=0;$e=0;$f=0;$g=0;
            $i=0;$k=0;
            $gio=0;
            $phut=0;
            $gio1=0;
            $phut1=0;
         foreach ($query2->result() as $row2)
         {
             
             $phut=$phut+substr($row2->overtime,3,2);
             $gio=$gio+substr($row2->overtime,0,2);
             $phut1=$phut%60;
             $gio1=(int)($phut/60)+$gio;
             
             
            switch ($row2->weekday)
            {
                case 'Monday': {$a++;break;}
                case 'Tuesday': {$b++;break;}
                case 'Wednesday': {$c++;break;}
                case 'Thursday': {$d++;break;}
                case 'Firday': {$e++;break;}
                case 'Saturday': {$f++;break;}
                case 'Sunday': {$g++;break;}
            } 
         }
         
         $detail="Detail of workday all Staff";
         $h=$a+$b+$c+$d+$e+$f;
         $i=$gio1.':'.$phut1;
         $k=$query2->num_rows()*8;
         
        //echo '</table>';
        /*echo '<table class="tablebg" cellspacing="1" align="right" border="1" width="900px">';
        echo '<tr><td colspan=6 align=right class=bar>'.$detail.'</td></tr>';
        echo "<tr>
                <td class=row1>Numbers of Monday</td>
                <td class=row2>$a</td>
            </tr>
            <tr>
                <td class=row1>Numbers of Tuesday</td>
                <td class=row2>$b</td>
            </tr>
            <tr>
                <td class=row1>Numbers of Wednesday</td>
                <td class=row2>$c</td>
            </tr>
            <tr>
                <td class=row1>Numbers of Thursday</td>
                <td class=row2>$d</td>
            </tr>
            <tr>
                <td class=row1>Numbers of Firday</td>
                <td class=row2>$e</td>
            </tr>
            <tr>
                <td class=row1>Numbers of Saturday</td>
                <td class=row2>$f</td>
            </tr>
            <tr>
                <td class=row1>Numbers of Sunday</td>
                <td class=row2>$g</td>
            </tr>
            <tr>
                <td class='total'>Numbers of Workday</td>
                <td class='total'>$h</td>
            </tr>
            <tr>
                <td class='total'>Numbers hours overtime of Workday</td>
                <td class='total'>$i</td>
            </tr>
            <tr>
                <td class='total'>Numbers hours of Workday</td>
                <td class='total'>$k:00</td>
            </tr>";
        echo '</table>';*/
?>
